<template>
	<page-meta :root-font-size="getRootFontSize()"></page-meta>
	<view class="mapsBox">
		<view class="topBox">
			<view class="status_bar"></view>
			<uni-nav-bar style="width: 750rpx; height: 44px;" @clickRight="showSetUp" color="#FDFDFD" :border="false" :shadow="false" background-color="#FBFBFF">
				<!-- <view class="titleImg"><image style="width: 100%; height: 100%;" mode="scaleToFill" src="/static/icon/logo_ctw@3x.png"></image></view> -->
				<!-- 			<view slot="left">
					<view class="leftIconBox"><uni-icons type="arrowleft" color="#000" size="18"></uni-icons></view>
				</view> -->
				<view slot="right"><uni-icons type="bars" color="#AEB0B3" size="28"></uni-icons></view>
			</uni-nav-bar>
		</view>

		<view :style="{ paddingTop: topBar }">
			<!-- 标题 -->
			<view class="titleBox">
				<view class="titleBoxcenter">
					<text>{{ i18n.ctwfont1 }}</text>
				</view>
				<!-- search模块 -->
				<view class="searchBox">
					<uni-row class="searchBoxrow">
						<view class="searchBoxcolTitle">{{ i18n.ctwfont2 }}</view>
						<view class="searchBoxcolInput">
							<uni-easyinput v-model="search.value1" trim suffixIcon="search" :placeholder="i18n.ctwfont46" clearable @confirm="searchSubmit"></uni-easyinput>
						</view>
						<view class="searchBoxcolTitle" style="margin-top: 5px;">{{ i18n.ctwfont6 }}</view>
						<view class="searchBoxcolInput" @tap="showDate = true">
							<uni-easyinput :styles="disableColor" :placeholder="i18n.ctwfont48" v-model="search.value3[0]" disabled suffixIcon="calendar" clearable></uni-easyinput>
							<view style="font-weight: 700; color: #AEB0B3; padding: 0 5px;">-</view>
							<uni-easyinput :styles="disableColor" :placeholder="i18n.ctwfont49" v-model="search.value3[1]" disabled suffixIcon="calendar" clearable></uni-easyinput>
						</view>
					</uni-row>
				</view>
			</view>
			<view class="zhuti" v-if="typeShow == 1">
				<view class="morenBox">
					<view>{{ i18n.ctwfont1 }}:</view>
					<view>{{ i18n.ctwfont46 }}</view>
					<view class="morenBoxMargin">{{ i18n.ctwfont47 }}:</view>
					<view>{{ i18n.ctwfont50 }}</view>
				</view>
			</view>
			<view class="zhuti" v-else-if="typeShow == 2">
				<tabBtn :modelData="tabList" :initIndex="tabIndex" @change="changeTab"></tabBtn>
				<!-- 小红线 -->
				<view class="honLine"></view>
				<view class="cardBox" :style="{ height: scrollBox }">
					<view class="cardBoxTotal" v-if="!loading">{{ i18n.ctwfont51 }} {{ total }} {{ i18n.ctwfont52 }}</view>
					<view class="loadingBox" v-if="loading"><uni-load-more color="#333" :showText="false" status="loading"></uni-load-more></view>
					<view v-else class="cardBoxArr" v-for="item in cardArrList" :key="item.billCode">
						<view>
							<view class="cardBoxItem">
								<view class="">
									{{ i18n.ctwfont14 }}:
									<text :selectable="true" style="color: #fff; margin-left: 10px;">{{ item.billCode }}</text>
								</view>
								<view class="">
									<button size="mini" @tap="getImg(item)" plain class="chaBtn" type="default">
										<uni-icons type="image" size="14" color="#fff" style="margin-right: 5px;"></uni-icons>
										{{ i18n.ctwfont22 }}
									</button>
								</view>
							</view>
							<view class="cardBoxneiron">
								<uni-row>
									<uni-col :span="24">
										<view class="cardBoxneironText">
											<view class="cardBoxneironTextL" style="width: 200rpx;">{{ i18n.ctwfont53 }}</view>
											<view class="cardBoxneironTextR">{{ item.infoStoreDetails.length > 0 ? item.infoStoreDetails[0].fitOutNo : '' }}</view>
										</view>
										<view class="cardBoxneironText">
											<view class="cardBoxneironTextL">{{ i18n.ctwfont23 }}</view>
											<view class="cardBoxneironTextR">{{ item.orderTime }}</view>
										</view>
										<view class="cardBoxneironText">
											<view class="cardBoxneironTextL">{{ i18n.ctwfont19 }}</view>
											<view class="cardBoxneironTextR">{{ item.actualReceiptAuditTime }}</view>
										</view>
										<!-- 				<view class="cardBoxneironText">
											<view class="cardBoxneironTextL">{{ i18n.ctwfont16 }}</view>
											<view class="cardBoxneironTextR">{{ paymentMethod(item.paymentTypeName) }}</view>
										</view> -->
										<view class="cardBoxneironText">
											<view class="cardBoxneironTextL">{{ i18n.ctwfont24 }}</view>
											<view class="cardBoxneironTextR">{{ transport(item.transportModeName) }}</view>
										</view>
									</uni-col>
								</uni-row>
							</view>
							<view class="cardBoxneironTextTwo" style="margin-bottom: 10px;background-color: #ffedef;">
								<view class="cardBoxneironTextL">{{ i18n.ctwfont17 }}</view>
								<view class="cardBoxneironTextR">{{ type(item.orderStatusType) }}</view>
							</view>
							<view class="cardBoxneironTextTwo" style="padding-bottom: 10px;">
								<view class="cardBoxneironTextL">
									<button @tap="goDetails(item)" size="mini" class="cardBoxneironTextBtn2" type="default">{{ i18n.ctwfont25 }}</button>
								</view>
								<view class="cardBoxneironTextR">
									<button @tap="goTracking(item)" size="mini" class="cardBoxneironTextBtn" type="default">{{ i18n.ctwfont26 }}</button>
								</view>
							</view>
						</view>
					</view>
					<view style="display: flex; justify-content: center; align-items: center;" v-show="cardArrList.length === 0 && cardArrList.length < 1 && !loading">
						<image style="width: 100px; height: 100px;" mode="scaleToFill" src="/static/icon/NoData.png"></image>
					</view>
					<view class="paginationBottom" v-show="!loading" v-if="cardArrList.length >= 1">
						<page-pagination
							class="paginationBoxL"
							mode="multi"
							color="#CD001B"
							:pageSize="pageSize"
							:showPageSize="7"
							forceEllipses
							:total="total"
							:currentPage="currentPage"
							@change="paginationChange"
						></page-pagination>
						<view class="paginationBoxR" v-show="false">
							<input type="number" class="paginationBoxRInput" placeholder="page" v-model="paginationNum" />
							<button size="mini" @tap="paginationBtn" class="paginationBoxRBtn" type="default">{{ i18n.ctwfont34 }}</button>
						</view>
					</view>
				</view>
			</view>
			<view class="zhuti" v-else><tracking-details :cardArrList="cardArrListType" @closeCardArr="closeCardArr" :isShowBar="false"></tracking-details></view>
		</view>
		<junDatetime
			:is_show="showDate"
			:start="formatDate(search.value2[0], true)"
			:end="formatDate(search.value2[1], true)"
			@closeIs_show="closeJunDate"
			@JunDateConfirm="JunDateConfirm"
		></junDatetime>
		<view class="mayiMissImg" v-if="typeShow == 1" :style="{ bottom: isIOS ? '-24px' : '10px' }">
			<!-- <image style="width: 200px; height: 250px;" src="/static/icon/superAnt/Tracking-02.png" mode=""></image> -->
			<image src="/static/icon/superAnt/Tracking-02.png" mode=""></image>
		</view>
		<!-- 查看图片 -->
		<uni-popup ref="ImgPopup" type="dialog" :mask-click="false">
			<view class="freightDocumentPopupBox">
				<view class="freightDocumentPopupBoxTop">
					<image class="freightDocumentPopupBoxTopImg" src="/static/icon/OneDrive_5_11-16-2021/2x/transportationImg.png" mode=""></image>
					<arprogress class="freightDocumentPopupBoxTopImgArprogress" :percent="percent" :width="110" activeColor="#01AD50" inactiveColor="#ececec" :borderWidth="10">
						<text style="color: #ececec;">{{ percent }}%</text>
					</arprogress>
				</view>
				<view class="freightDocumentPopupBoxBottom">
					<view class="freightDocumentPopupBoxBottomTitle">{{ i18n.ctwfont22 }}</view>
					<view class="freightDocumentPopupBoxBottomCenter">{{ failurePrompt }}</view>
					<button size="mini" @tap="maskClickclose" class="freightDocumentPopupBoxBottomCenterBtn" type="default">{{ i18n.ctwfont45 }}</button>
				</view>
			</view>
		</uni-popup>
		<!-- 设置 -->
		<uni-popup ref="SetUpPopup" type="center" :animation="false"><set-up-pages ref="showPopup" @closePopUp="closePopUp" /></uni-popup>
		<!-- 退出 -->
		<sign-out ref="signOutBox" />
		<lb-tabbar ref="tabbar" :value="$store.state.tabActive" :animate="$store.state.animate" :placeholder="true">
			<lb-tabbar-item
				v-for="item in $store.state.tabbars"
				:key="item.pagePath"
				:name="item.pagePath"
				:icon="item.iconPath"
				:selectedIconPath="item.selectedIconPath"
				:dot="item.dot"
				:info="item.info"
				:raisede="item.raisede"
				icon-prefix="iconfont"
				@click="handleTabbarItemClick"
			>
				{{ item.text }}
			</lb-tabbar-item>
		</lb-tabbar>
	</view>
</template>
<style lang="scss" scoped>
::v-deep .uni-easyinput__content {
	min-height: 28px;
	border-radius: 20px;
}
::v-deep .is-disabled {
	background-color: #fff;
}
::v-deep .input-value {
	line-height: 28px;
}

::v-deep .uni-input-input {
	font-size: $uni-font-size-custom-b;
}
.mapsBox {
	position: fixed;
	background-color: #fbfbff;
	width: 100%;
	height: 100%;
}

.mayiMissImg {
	position: fixed;
	bottom: -24px;
	left: 50%;
	transform: translateX(-50%);
}
.loadingBox {
	height: 200px;
	display: flex;
	justify-content: center;
	align-items: center;
	// background-color: rgba(0, 0, 0, 0.5);
}
.titleImg {
	position: absolute;
	left: 50%;
	transform: translateX(-50%);
	width: 60px;
	height: 30px;
	// margin: 0 auto;
	border-radius: 50%;
	overflow: hidden;
}
.leftIconBox {
	width: 25px;
	height: 25px;
	background-color: #fff;
	border-radius: 50%;
	display: flex;
	justify-content: center;
	align-items: center;
	margin-left: 15px;
}
.topBox {
	position: fixed;
	top: 0;
	left: 0;
	z-index: 10;
	// 顶部部分
	.status_bar {
		height: var(--status-bar-height);
		background-color: #fbfbff;
		width: 100%;
	}
}
.zhuti {
	margin-top: 85px;
	box-sizing: border-box;
	background-color: #fbfbff;
	.honLine {
		margin: 0 15px;
		padding-top: 5px;
		border-bottom: 2px solid #d80c24;
	}
	.morenBox {
		font-size: $uni-font-size-custom-f;
		color: #77838f;
		text-align: center;
		padding-top: 100rpx;

		.morenBoxMargin {
			margin-top: 50rpx;
		}
	}
	.cardBox {
		padding: 0 15px;
		padding-top: 10px;
		overflow-y: scroll;
		.cardBoxTotal {
			padding-bottom: 10px;
			font-size: $uni-font-size-custom-f;
			font-weight: 700;
			color: #ff4a62;
		}
		.cardBoxArr {
			background-color: #fff;
			border-radius: 10px;
			border: 1px solid #f3f3f3;
			overflow: hidden;
			margin-bottom: 15px;
			box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
			.cardBoxItem {
				display: flex;
				justify-content: space-between;
				align-items: center;
				padding: 0 10px;
				box-sizing: border-box;
				height: 35px;
				background-color: #f77687;
				font-size: $uni-font-size-custom-d;
				color: #fff;
				.chaBtn {
					padding: 0 10px;
					border-radius: 5px;
					color: #ffffff;
					line-height: 1.8;
					margin-top: 3px;
					border: 1px solid #f77687;
				}
			}
			.cardBoxneironTextTwo {
				display: flex;
				height: 25px;
				line-height: 25px;
				justify-content: space-between;
				align-items: center;
				padding: 0 10px;
				.cardBoxneironTextL {
					font-size: $uni-font-size-custom-b;
					line-height: 14px;
					color: #71727c;
				}
				.cardBoxneironTextR {
					font-size: $uni-font-size-custom-b;
					color: #298a1b;
					line-height: 14px;
				}
				.cardBoxneironTextBtn {
					width: 100%;
					background-color: #0f2671;
					padding: 2px 15px;
					font-size: $uni-font-size-custom-b;
					border-radius: 10px;
					color: #ffffff;
					line-height: 1.6;
					// margin-top: 20px;
				}
				.cardBoxneironTextBtn2 {
					background-color: #ff576d;
					padding: 2px 15px;
					border-radius: 10px;
					font-size: $uni-font-size-custom-b;
					color: #fff;
					line-height: 1.7;
					// margin-top: 20px;
				}
			}
			.cardBoxneiron {
				padding: 10px 10px 0 10px;
				box-sizing: border-box;
				.cardBoxneironText {
					display: flex;
					height: 25px;
					line-height: 25px;
					justify-content: space-between;
					align-items: center;
					.cardBoxneironTextL {
						// width: 160rpx;
						font-size: $uni-font-size-custom-b;
						line-height: 14px;
						color: #71727c;
					}
					.cardBoxneironTextR {
						font-size: $uni-font-size-custom-b;
						// width: 200rpx;
						line-height: 14px;
					}
					.cardBoxneironTextBtn {
						width: 100%;
						background-color: #0f2671;
						padding: 2px 15px;
						font-size: $uni-font-size-custom-b;
						border-radius: 10px;
						color: #ffffff;
						line-height: 1.6;
						// margin-top: 20px;
					}
					.cardBoxneironTextBtn2 {
						background-color: #ff576d;
						padding: 2px 15px;
						border-radius: 10px;
						font-size: $uni-font-size-custom-b;
						color: #fff;
						line-height: 1.7;
						// margin-top: 20px;
					}
				}
			}
		}
	}
	.paginationBottom {
		padding: 20px 0;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		.paginationBoxL {
			flex: 2;
			height: 30px;
			line-height: 30px;
		}
		.paginationBoxR {
			flex: 1;
			display: flex;
			justify-content: space-between;
			.paginationBoxRInput {
				border: 1px solid #efefef;
				border-radius: 5px;
				margin: 0 5px;
				padding: 5px;
				height: 32px;
				// line-height: 32px;
				width: 50px;
				text-align: center;
				box-sizing: border-box;
			}
			.paginationBoxRBtn {
				background-color: #cd001b;
				padding: 0 10px;
				border-radius: 5px;
				color: #ffffff;
				// line-height: 2;
			}
		}
	}
}
.titleBox {
	position: relative;
	margin-bottom: 5px;
	background-color: #fbfbff;
	height: 100px;
	border-bottom-right-radius: 10px;
	border-bottom-left-radius: 10px;
	.titleBoxcenter {
		height: 30px;
		line-height: 30px;
		text-align: center;
		font-size: $uni-font-size-custom-j;
		color: #cd001b;
	}
	.searchBox {
		margin-top: 10px;
		padding: 0 15px;
		.searchBoxrow {
			background-color: #fff;
			padding: 15px;
			box-sizing: border-box;
			border-radius: 10px;
			box-shadow: 0 3px 5px rgba(0, 0, 0, 0.2);
			.searchBoxcolTitle {
				text-align: center;
				font-size: $uni-font-size-custom-e;
				color: #333;
			}
			.searchBoxcolInput {
				display: flex;
				justify-content: space-between;
				align-items: center;
				::v-deep .is-disabled {
					color: #333;
				}
			}
		}
	}
}
.freightDocumentPopupBox {
	width: 500rpx;
	// height: 600rpx;
	border-radius: 10px;
	background-color: #27387d;
	.freightDocumentPopupBoxTop {
		height: 200rpx;
		position: relative;
		.freightDocumentPopupBoxTopImg {
			width: 250rpx;
			height: 250rpx;
			position: absolute;
			top: -30rpx;
			left: 51%;
			transform: translateX(-50%);
		}
		.freightDocumentPopupBoxTopImgArprogress {
			position: absolute;
			top: 46%;
			left: 50.5%;
			transform: translateX(-50%);
		}
	}
	.freightDocumentPopupBoxBottom {
		width: 100%;
		height: 400rpx;
		border-radius: 10px;
		background-color: #fff;
		padding: 20px;
		box-sizing: border-box;
		.freightDocumentPopupBoxBottomTitle {
			padding-top: 10px;
			color: #d81a3f;
			font-size: $uni-font-size-custom-j;
		}
		.freightDocumentPopupBoxBottomCenter {
			padding-top: 5px;
			font-size: $uni-font-size-custom-e;
		}
		.freightDocumentPopupBoxBottomCenterBtn {
			position: absolute;
			bottom: 20px;
			left: 50%;
			transform: translateX(-50%);
			background-color: #81b2ff;
			padding: 0 35px;
			border-radius: 5px;
			color: #ffffff;
		}
	}
}
</style>
<script>
import junDatetime from '@/components/uni-jun-datetime/index.vue';
import tabBtn from '@/pages/maps/tabBtn.vue';
import setUpPages from '@/pages/setUpPages/index.vue';
import signOut from '@/pages/setUpPages/signOut.vue'; // 退出登录
import { getStorage } from '@/utils/setStorage.js';
import arprogress from '@/components/ar-circle-progress/ar-circle-progress.vue';
import { codeMapFun } from '@/utils/codeMap.js';
import { lastMonthDate } from '@/utils/lastMonthDate.js';
import baseFont from '@/utils/baseFont.js';
import trackingDetails from '@/pages/maps/trackingDetails.vue';
// tababr
import lbTabbar from '@/pages/lb-tabbar/lb-tabbar.vue';
import lbTabbarItem from '@/pages/lb-tabbar/lb-tabbar-item.vue';
export default {
	extends: baseFont,
	data: function() {
		return {
			typeShow: 1, // 当前显示页面
			showDate: false, // 时间组件
			topBarHeight: 0, // 导航栏高度
			windowHeight: 0, // 手机高度
			back_k: 0,
			selectIndex: 0,
			paginationNum: '', // 分页输入值
			popupIsShow: false, // 打开设置的标识
			signOutShow: false, // 退出登录
			islanguage: getStorage('language') || 'zh',
			// lastMonthDate(), this.formatDate(new Date())
			// this.formatDateTwo(lastMonthDate()), this.formatDateTwo(new Date())
			search: {
				value1: '',
				value2: [],
				value3: []
			},
			pageSize: 10, // 条数
			currentPage: 1, // 页数
			total: 0, // 总数
			loading: false, // 加载
			loadingTime: '', // 定时
			tabIndex: 0, // 选中状态背景色位置
			// 订单arr
			cardArrList: [],
			cardArrListType: {}, // 详情数据
			shipmentImage: '', // 关闭导出图片
			cdStop: null, // 请求终止
			percent: 0,
			ssBox: null,
			CustomerCodeTwoShow: false,
			CustomerCodeTwoNum: 0, // 当前权限
			failurePrompt: this.$t('maps.ctwfont43'),
			disableColor: {
				disableColor: '#fff',
				borderColor: '#e5e5e5',
				color: '#333'
			}
		};
	},
	onLoad() {
		// 拦截物理返回键
		this.goBackBox();
	},
	onUnload() {
		uni.$off('goBack_k', this.goBackBox2);
	},
	onShow() {
		// this.getList();
	},
	created() {
		const that = this;
		uni.getSystemInfo({
			success(res) {
				that.topBarHeight = res.statusBarHeight;
				that.windowHeight = res.windowHeight;
			}
		});
	},
	onHide() {
		this.$refs.SetUpPopup.close();
		this.popupIsShow = false;
		this.$refs.signOutBox.close();
	},
	components: { setUpPages, signOut, arprogress, lbTabbar, lbTabbarItem, tabBtn, junDatetime, trackingDetails },
	computed: {
		topBar() {
			let num = 0;
			num = this.topBarHeight + 44; // 44是顶部高度 + 64
			return num + 'px';
		},
		isIOS() {
			if (uni.getSystemInfoSync().platform == 'android') {
				return true;
			} else {
				return false;
			}
		},
		scrollBox() {
			let num = 0;
			// 94
			num = this.windowHeight - (this.topBarHeight + 256 + 144);
			if (uni.getSystemInfoSync().platform == 'ios') {
				num = num - 36;
			}
			return num + 'px';
		},
		i18n() {
			return this.$t('maps');
		},
		isGoodsListImage() {
			return function(val) {
				const isoks = val.billCode.substr(0, 1);
				if (Number(isoks) === 8) {
					return true;
				} else {
					return false;
				}
			};
		},
		type() {
			return function(val) {
				let text = '';
				if (Number(val) === 1) {
					text = this.$t('maps').ctwfont27;
				} else if (Number(val) === 2) {
					text = this.$t('maps').ctwfont9;
				} else if (Number(val) === 3) {
					text = this.$t('maps').ctwfont10;
				} else if (Number(val) === 4) {
					text = this.$t('maps').ctwfont29;
				} else if (Number(val) === 5) {
					text = this.$t('maps').ctwfont13;
				} else {
					text = this.$t('maps').ctwfont31;
				}
				return text;
			};
		},
		tabList() {
			const arr = [
				{
					label: this.$t('maps').ctwfont8,
					num: 0
				},
				{
					label: this.$t('maps').ctwfont9,
					num: 0
				},

				{
					label: this.$t('maps').ctwfont10,
					num: 0
				},
				{
					label: this.$t('maps').ctwfont11,
					num: 0
				},
				{
					label: this.$t('maps').ctwfont12,
					num: 0
				},
				{
					label: this.$t('maps').ctwfont13,
					num: 0
				}
			];
			return arr;
		},
		// 支付方式
		paymentMethod() {
			return function(val) {
				if (val === '急转') {
					return this.$t('maps').ctwfont36;
				} else if (val === '转账') {
					return this.$t('maps').ctwfont37;
				} else if (val === '先付款再送货') {
					return this.$t('maps').ctwfont38;
				} else {
					return val;
				}
			};
		},
		// 运输方式
		transport() {
			return function(val) {
				if (val === '海运') {
					return this.$t('maps').ctwfont39;
				} else if (val === '空运') {
					return this.$t('maps').ctwfont40;
				} else if (val === 'EK') {
					return this.$t('maps').ctwfont41;
				} else {
					return val;
				}
			};
		}
	},
	methods: {
		handleTabbarItemClick(e) {
			const token = getStorage('token');
			if (token === undefined || token === null || token === '') {
				let currentRoutes = getCurrentPages(); // 获取当前打开过的页面路由数组
				let currentRoute = currentRoutes[currentRoutes.length - 1].route; //获取当前页面路由
				let currentParam = currentRoutes[currentRoutes.length - 1].options; //获取路由参数
				// 拼接参数
				let param = '';
				for (let key in currentParam) {
					param += '?' + key + '=' + currentParam[key];
				}
				let localRoute = '/' + currentRoute + param;
				if (e.name == localRoute) {
					return false;
				} else {
					if (e.name === '/pages/businessCard/index' || e.name === '/pages/home/index') {
						// #ifdef APP-PLUS
						uni.redirectTo({
							url: e.name
						});
						// #endif
						// #ifdef H5
						this.$Router.push(e.name);
						// #endif
					} else {
						// #ifdef APP-PLUS
						uni.redirectTo({
							url: '/pages/home/index'
						});
						// #endif
						// #ifdef H5
						this.$Router.push('/pages/home/index');
						// #endif
					}
				}
			} else {
				// this.$store.state.tabActive = e.name;
				let currentRoutes = getCurrentPages(); // 获取当前打开过的页面路由数组
				let currentRoute = currentRoutes[currentRoutes.length - 1].route; //获取当前页面路由
				let currentParam = currentRoutes[currentRoutes.length - 1].options; //获取路由参数
				// 拼接参数
				let param = '';
				for (let key in currentParam) {
					param += '?' + key + '=' + currentParam[key];
				}
				let localRoute = '/' + currentRoute + param;
				if (e.name == localRoute) {
					return false;
				} else {
					// #ifdef APP-PLUS
					uni.redirectTo({
						url: e.name
					});
					// #endif
					// #ifdef H5
					this.$Router.push(e.name);
					// #endif
				}
			}
		},
		goBackBox() {
			// const that = this;
			uni.$on('goBack_k', this.goBackBox2);
		},
		goBackBox2(data) {
			this.back_k < 0 ? (this.back_k = 0) : (this.back_k = this.back_k);
			if (data) {
				if (this.popupIsShow) {
					this.$refs.SetUpPopup.close();
					this.popupIsShow = false;
				} else if (this.signOutShow) {
					this.$refs.signOutBox.close();
					this.signOutShow = false;
				} else if (this.ImgPopup) {
					this.$refs.ImgPopup.close();
					this.percent = 0;
					clearTimeout(this.shipmentImage);
					this.ImgPopup = false;
					this.cdStop.abort();
				} else {
					let main = plus.android.runtimeMainActivity();
					if (this.back_k > 0) {
						this.back_k = 0;
						return main.moveTaskToBack(false);
						// return plus.runtime.quit();
					} else {
						const pages = getCurrentPages();
						if (pages.length === 1) {
							this.back_k++;
							setTimeout(() => {
								this.back_k--;
							}, 1000);
							// uni.showToast({
							// 	title: '再按一次退出应用',
							// 	icon: 'none',
							// 	duration: 1000
							// });
						}
					}
				}
			}
		},
		// 搜索
		searchSubmit() {
			if (this.search.value1) {
				this.tabIndex = 0;
				this.currentPage = 1; // 页数
				this.typeShow = 3;
				this.search.value2 = [lastMonthDate(), this.formatDate(new Date())];
				this.search.value3 = ['', ''];
				this.getList();
			} else {
				uni.showToast({
					title: '请输入订单号',
					icon: 'none',
					duration: 1000
				});
			}
		},
		// tab切换
		changeTab(e) {
			this.tabIndex = e;
			this.currentPage = 1; // 页数
			this.typeShow = 2;
			this.getList();
		},
		// 分页器
		paginationChange(e) {
			this.currentPage = e; // 页数
			this.typeShow = 2;
			this.getList();
		},
		// 输入跳转
		paginationBtn() {
			const num = this.paginationNum > this.total / 10 ? this.total / 10 : this.paginationNum;
			this.currentPage = Math.ceil(num) === 0 ? 1 : Math.ceil(num); // 页数
			this.paginationNum = Math.ceil(num) === 0 ? 1 : Math.ceil(num);
			this.getList();
		},
		// 打开设置
		showSetUp() {
			this.$refs.SetUpPopup.open('right');
			this.popupIsShow = true;
		},
		// 关闭设置
		closePopUp(val) {
			if (val) {
				this.$refs.SetUpPopup.close();
				this.popupIsShow = false;
			} else {
				this.$refs.SetUpPopup.close();
				this.popupIsShow = false;
				this.$refs.signOutBox.open();
				this.signOutShow = true;
			}
			this.islanguage = getStorage('language') || 'zh';
		},
		// 获取数据
		async getList() {
			this.loading = true;
			this.loadingTime = setTimeout(() => {
				this.loading = false;
			}, 5000);
			const { value1, value2 } = this.search;
			const user = JSON.parse(getStorage('userconter'));
			let orderTypeNum = 0;
			if (this.tabIndex >= 2) {
				orderTypeNum = this.tabIndex + 1;
			} else {
				orderTypeNum = this.tabIndex;
			}
			const params = {
				orderType: orderTypeNum,
				createCustomerCode: user.customerCode,
				customerCode: user.customerCode,
				page: this.currentPage,
				limit: this.pageSize,
				orderNumber: value1,
				beginDate: this.formatDate(value2[0]),
				endDate: this.formatDate(value2[1])
			};
			const { data: res } = await this.$http(true, 'api/E3/orderList', params, 'GET');
			this.loading = false;
			clearTimeout(this.loadingTime);
			if (res.errno === 0) {
				if (res.data) {
					this.total = res.data.total;
					res.data.list.forEach(item => {
						if (item.orderTime) {
							item.orderTime = item.orderTime.substring(0, 10);
						}
					});
					if (this.typeShow == 2) {
						this.cardArrList = res.data.list;
					} else if (this.typeShow == 3) {
						this.cardArrListType = res.data.list[0];
					} else {
						this.cardArrList = res.data.list;
					}
				} else {
					this.total = 0;
					this.cardArrList = [];
					this.cardArrListType = {};
				}
			} else {
				this.cardArrList = [];
				this.cardArrListType = {};
				const err = codeMapFun().find(item => item[res.errno]);
				if (err) {
					uni.showToast({
						title: err[res.errno],
						icon: 'none',
						position: 'top'
					});
				} else {
					uni.showToast({
						title: res.errmsg,
						icon: 'none',
						position: 'top'
					});
				}
			}
		},
		// 时间处理
		formatDate(value, type) {
			const dt = new Date(value);
			const y = dt.getFullYear();
			const m = (dt.getMonth() + 1 + '').padStart(2, 0);
			const d = (dt.getDate() + '').padStart(2, 0);
			if (type) {
				return new Date(value).getTime() - 8 * 60 * 60 * 1000;
			} else {
				return `${y}-${m}-${d}`;
			}
		},
		formatDateTwo(value) {
			const dt = new Date(value);
			const y = dt.getFullYear();
			const m = (dt.getMonth() + 1 + '').padStart(2, 0);
			const d = (dt.getDate() + '').padStart(2, 0);
			return `${d}-${m}-${y}`;
		},
		// 时间
		datetimeChange(e) {
			this.search.value2 = e;
		},
		// 主动关闭
		maskClickclose(e) {
			if (e.type) {
				clearInterval(this.ssBox);
				this.percent = 0;
				this.$refs.ImgPopup.close();
				this.cdStop.abort();
			}
		},
		// 预览图片
		async getImg(img) {
			this.ImgPopup = true;
			this.$refs.ImgPopup.open();
			this.failurePrompt = this.$t('maps.ctwfont43');
			this.ssBox = setInterval(() => {
				if (this.percent >= 99) {
					clearInterval(this.ssBox);
				} else {
					this.percent += 1;
				}
			}, 150);
			this.shipmentImage = setTimeout(() => {
				uni.showToast({
					title: 'overtime!',
					icon: 'none',
					position: 'top'
				});
				clearInterval(this.ssBox);
				this.percent = 0;
				this.$refs.ImgPopup.close();
				this.cdStop.abort();
			}, 60000);
			const { value2 } = this.search;
			const that = this;
			const user = JSON.parse(getStorage('userconter'));
			const params = {
				customerCode: user.customerCode,
				orderNumber: img.billCode,
				beginDate: this.formatDate(value2[0]),
				endDate: this.formatDate(value2[1])
			};
			const { data: res } = await this.$http(true, 'api/E3/shipmentImage', params, 'GET', cd => {
				that.cdStop = cd;
			});
			this.percent = 100;
			clearTimeout(this.shipmentImage);
			// this.$refs.ImgPopup.close();
			this.ImgPopup = false;
			if (res.errno === 0) {
				if (res.data) {
					clearInterval(this.ssBox);
					this.percent = 0;
					this.$refs.ImgPopup.close();
					setTimeout(() => {
						uni.showTabBar();
					}, 500);
					// 预览图片
					uni.previewImage({
						urls: [res.data]
					});
				}
			} else {
				clearInterval(this.ssBox);
				this.percent = 0;
				this.failurePrompt = this.$t('maps.ctwfont44');
				// uni.showToast({
				// 	title: res.errmsg || 'request was aborted',
				// 	icon: 'none',
				// 	position: 'top'
				// });
			}
			// const isoks = img.billCode.substr(0, 1);
			// if (Number(isoks) === 8) {
			// }
		},
		// 查看详情
		goDetails(val) {
			if (val.billCode) {
				this.tabIndex = 0;
				this.currentPage = 1; // 页数
				this.typeShow = 3;
				this.search.value1 = val.billCode;
				this.search.value2 = [lastMonthDate(), this.formatDate(new Date())];
				this.search.value3 = ['', ''];
				this.getList();
			}

			// // #ifdef APP-PLUS
			// uni.redirectTo({
			// 	url: `/pages/maps/orderDetails?num=${val.billCode}&date=${this.search.value2}&url=/pages/maps/index&customerCode=${val.customerCode}`
			// });
			// // #endif
			// // #ifdef H5
			// this.$Router.push(`/pages/maps/orderDetails?num=${val.billCode}&date=${this.search.value2}&url=/pages/maps/index&customerCode=${val.customerCode}`);
			// // #endif
		},
		// 订单跟踪
		goTracking(val) {
			// #ifdef APP-PLUS
			uni.redirectTo({
				url: `/pages/maps/orderTracking?num=${val.billCode}&url=/pages/maps/index`
			});
			// #endif
			// #ifdef H5
			this.$Router.push(`/pages/maps/orderTracking?num=${val.billCode}&url=/pages/maps/index`);
			// #endif
		},
		// 关闭时间范围选择器
		closeJunDate() {
			this.showDate = false;
		},
		// 选中的时间
		JunDateConfirm(e) {
			this.search.value1 = '';
			this.search.value2 = [e.start, e.end];
			this.search.value3 = [e.startShow, e.endShow];
			this.tabIndex = 0;
			this.currentPage = 1; // 页数
			this.typeShow = 2;
			this.getList();
		},
		// 关闭详情
		closeCardArr() {
			this.search.value1 = '';
			this.search.value2 = [];
			this.search.value3 = ['', ''];
			this.typeShow = 1;
		}
	}
};
</script>
